package com.xiaobai.rest;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/user")
public class ConsulUserController {


    @RequestMapping("/getUser")
    @HystrixCommand(fallbackMethod = "test")
    public String getUser(int id) {

        log.info("用户传入信息:{}", id);
        if (id < 0) {
            throw new RuntimeException("断路由");
        }
        return "用户信息:" + id;
    }

    public String test(int id) {
        return "退回方法" + id;
    }

}
